package com.ipzoe.common.repository;

import com.ipzoe.common.bean.entity.Role;
import com.ipzoe.common.util.DefaultMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 角色Repository
 * <p>
 * Created 2018/01/19.
 *
 * @author pfzhang
 */
@Mapper
public interface RoleRepository extends DefaultMapper<Role> {

    /**
     * 根据关键字查询角色
     *
     * @param key 关键字
     * @return 角色对象分页集合
     */
    @Select("select * from role where del_flag = 0 and name like #{0} and id <> 1 order by last_modified_time desc")
    List<Role> search(String key);

    /**
     * 根据角色名获取角色对象
     *
     * @param name 角色名
     * @return 角色对象
     */
    @Select("select * from role where name = #{0} and del_flag = 0")
    Role findByName(String name);
}
